/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_FILEMGMT_CLOUD_SYNC_POWER_STATUS_H
#define OHOS_FILEMGMT_CLOUD_SYNC_POWER_STATUS_H

#include <functional>
#include <mutex>
#include <map>
#include <vector>
#include "data_sync_manager.h"
#include "sync_state_manager.h"
#include "standby_service_subscriber_stub.h"
#include "standby_service_client.h"

namespace OHOS::FileManagement::CloudSync {
class PowerStatusListener : public OHOS::DevStandbyMgr::StandbyServiceSubscriberStub {
public:
    void OnPowerOverused(const std::string& module, uint32_t level) override;
public:
    PowerStatusListener() = default;
    ~PowerStatusListener() = default;
    void SetDataSycner(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager);
    uint32_t GetPowerLevel();
private:
    std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager_ = nullptr;
    uint32_t powerLevel_ = 0;
};

class PowerStatus {
public:
    enum POWER_LEVEL {
        NORMAL,
        MINOR,
        WARNING,
        SERIOUS,
        EXTREME,
        FATAL
    };
    
    static PowerStatus& GetInstance();
    ~PowerStatus() = default;
    uint32_t GetPowerLevel();
    void InitPowerStatus(std::shared_ptr<CloudFile::DataSyncManager> dataSyncManager);
    void UnInitPowerStatus();
    
private:
    std::mutex initMutex_;
    OHOS::sptr<PowerStatusListener> listener_;
    bool init_;
};

} // OHOS

#endif // OHOS_FILEMGMT_CLOUD_SYNC_POWER_STATUS_H